<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0055)http://115.28.87.22:8888/business/BusinessDragForm.html -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>拖图下单 | 管理易-广告加工制作管理软件  企业版 9.28  | 易凯软件</title>
<script src="../js/minierp.js"></script>

<link rel="stylesheet" type="text/css" href="../css/base.css">
<style type="text/css">
<!--
.DragOver{
	border:2px dashed #555;
	border-radius:7px;
	cursor:default;
	border-color:#f00;
	border-style:solid;
	box-shadow:inset 0 3px 4px #888;
}
-->
</style>
<script src="../js/jquery.js"></script>
<script src="../js/popup_ext.js"></script>
<script src="../js/EkImgParser.js"></script>
<script src="../js/exif.js"></script>
<script language="javascript">
	function doCancel(){
		parent.ClosePop();
	}
	function doInit(){
		if(document.addEventListener){
			var fdArea=document.getElementById("filedrag_area");
			if(fdArea){
				fdArea.addEventListener("dragover",function(e){fileDragHover(e,fdArea.id)},false);
				fdArea.addEventListener("dragleave",function(e){fileDragHover(e,fdArea.id)},false);
				fdArea.addEventListener("drop",function(e){fileSelectHandler(e,fdArea.id)},false);
			}
		}
	}
	function fileDragHover(e,divId){
		e.stopPropagation();//停止事件的传播,阻止它被分派到其他 Document 节点
		e.preventDefault();//通知浏览器不要执行与事件关联的默认动作(否则浏览器会显示文件)
		var elem=e.target;
		while(elem.id!=divId){
			elem=elem.parentNode;
		}
		elem.className=(e.type=="dragover"?"DragOver":"");
	}
	
	var json,fileArr,statArr;
	function fileSelectHandler(e,divId){
		fileDragHover(e,divId);
		
		document.getElementById("LoadProcess").style.top=getTopPos(document.getElementById("mark_tbl"))+50+"px";
		document.getElementById("LoadProcess").style.left=getleftPos(document.getElementById("mark_tbl"))+200+"px";
		$("#LoadProcess").show();
		
		json = {};
		json.items=[];
		fileArr=[];
		statArr=[];
		
		var files=e.dataTransfer.files;
		for(var i=0;i<files.length;i++){
			var fn=files[i].name;
			
			var arr=fn.split("-");
			if(arr.length<6){
				continue;
			}
			fileArr.push(files[i]);
			statArr.push("N");
		}
		
		if(fileArr.length==0){
			$("#LoadProcess").hide();
			ShowAlert('提示框','文件名称格式不符合规定！',200,100);
		}else{
			setTimeout("checkStat()",300);
			
			for(var i=0;i<fileArr.length;i++){
				parseFile(fileArr[i],i);
			}
		}
	}
	function parseFile(file,index){
		var fn=file.name;
		var li=fn.lastIndexOf(".");
		if(li!=-1){
			fn=fn.substring(0,li);
		}
		
		var cont="";
		var sInde=fn.lastIndexOf("【");
		var eInde=fn.lastIndexOf("】");
		if(sInde!=-1 && eInde!=-1){
			cont=fn.substring(sInde+1,eInde);
			fn=fn.substring(0,sInde);
		}else{
			cont=fn;
		}
		
		var arr=fn.split("-");
		if(index==0){
			json.estName=arr[0];
		}
		
		var reader = new FileReader();
		reader.onload = function(e){
			var imgJson=EkImgParser.parse(e.target.result);//ArrayBuffer
			
			var lt="M";
			var widt=imgJson.width;
			var heig=imgJson.height;
			var spec="";
			if(widt!=""){
				if(lt=="M"){
					widt=parseScale(widt/100,3);
					heig=parseScale(heig/100,3);
					spec=widt+"m x "+heig+"m";
				}else{//MM
					widt=parseScale(accMul(widt,10),3);
					heig=parseScale(accMul(heig,10),3);
					spec=widt+"mm x "+heig+"mm";
				}
			}
			
			var item={"amou":arr[1],"mtName":arr[2],"prodName":arr[3],"spec":spec,"requ":arr[5],"widt":widt,"heig":heig,"lt":lt,"cont":cont};
			json.items.push(item);
			statArr[index]="Y";
		};
		reader.readAsArrayBuffer(file);
	}
	function checkStat(){
		var allComp=true;
		for(var i=0;i<statArr.length;i++){
			if(statArr[i]=="N"){
				allComp=false;
				break;
			}
		}
		if(!allComp){
			setTimeout("checkStat()",300);
		}else{
			var xmlHttp=createXMLHttpRequest();
			var url="../base/GetEstablishment.html?est_type=CLIENT&est_name="+encodeURIComponent(json.estName);
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState == 4) {
					if (xmlHttp.status == 200) {
						json.estId=xmlHttp.responseText;
						
						parent.popRetVal=json;
						parent.ClosePop();
					}
				}
			}
			xmlHttp.send(null);
		}
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onload="doInit();" class="sheet modal-dialog" style=" padding-top:10px;">
<div class="sheet-main" style="width:530px;" id="bodyDiv">
	<div class="sheet-list" style="width:100%;">
		<div class="modal-main search-business">
			<div style="width:100%;">
	 			
				
<script language="javascript">
	var formErrorIndex=0;
	var formErrorMsg="";
	var formErrorObjId="";
	function setFormErrorMsg(msg,index,objId){
		if(formErrorIndex==0 || formErrorIndex>index){
			if(msg!=null && msg!=""){
				formErrorIndex=index;
				formErrorMsg=msg;
				formErrorObjId=objId;
			}
		}
	}
	function showFormErrorMsg(){
		if(formErrorIndex!=0){
			document.getElementById("errorMsgTr").style.display="";
			document.getElementById("errorMsgDiv").innerHTML=formErrorMsg;
			if(formErrorObjId!=null && formErrorObjId!=""){
				document.getElementById(formErrorObjId).focus();
			}
		}
	}
	function goNextInput(objId){
		var obj=null;
		if(objId!=null && objId!=''){
			obj=document.getElementById(objId);
		}
		if(window.event.keyCode==13){
			if(obj!=null){
				obj.focus();
			}else if(window.doSave){
				doSave();
			}
		}
	}
</script>
<h3>拖图下单</h3>
<table width="96%" border="0" cellpadding="0" cellspacing="0" align="center">
	<tbody><tr id="errorMsgTr" style="display:none">
	  <td colspan="2">
	  	<div class="msg-error" id="errorMsgDiv">
      	
      	</div>
	  </td>
	</tr>
</tbody></table>
				
				<div class="blank12"></div>
				
				<div id="filedrag_area">
					<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0" id="mark_tbl">
						<tbody><tr>			   	
					      	<th style="width:20%">文件名格式：</th>
					      	<td style="width:80%">客户名称-<span style="color:red">数量</span>-项目类型-材质-规格-制作要求【内容】.jpg</td>
						</tr>
						<tr>			   	
					      	<th>例如：</th>
					      	<td>易凯软件-<span style="color:red">1个</span>-喷绘-3号布-4.7X2.4m-折边打眼【管理易】.jpg</td>
						</tr>
					</tbody></table>
					
					<table border="0" cellspacing="2" cellpadding="2" align="center" class="table-c">
						<tbody><tr>
							<td align="right" class="give" style="width:42px;">注：</td>
							<td class="give">1、请把同一个客户的图片多选，拖到这个区域，系统可以自动开单</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td class="give">2、文件必须按上面的规则命名，系统才能自动识别，自动填写业务单</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td class="give">3、文件名的分隔符是英文状态的 - ，文件格式必须是jpg文件</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td class="give">4、文件名的【】可以填写原文件名，方便和客户对帐</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td class="give">5、系统自动读取图片的规格，而文件名里的规格仅做参考，系统不读取</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td class="give">6、请将IE浏览器升级到IE10或以上版本，系统才能读取图片尺寸</td>
						</tr>
					</tbody></table>
				</div>
			</div>
		</div>
	</div>
	<div class="modal-buttom">
		<input type="button" class="buttom-a" value=" 取 消 " onclick="doCancel();">	
	</div>
</div>

<div id="LoadProcess" style="position:absolute; left:50%;top:50%; width:200px; height:100px; margin-top:-50px;margin-left:-100px;z-index:1; border:solid #000 5px;background-color:White;display:none">
	<table border="0" align="center" style="height:100%;">
		<tbody><tr>
			<td style="valign:middle">
				<img src="../images/loading.gif">
				请稍候...
			</td>
		</tr>
	</tbody></table>
</div>

</body></html>